
//
//  UITextField+Commons.m
//  Categorys
//
//  Created by taihankeji on 2017/5/31.
//  Copyright © 2017年 taihankeji. All rights reserved.
//

#import "UITextField+Commons.h"

@implementation UITextField (Commons)


// 通过attributedPlaceholder属性修改占位文字颜色
- (void)placeholderColor:(UIColor *)color {
    NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:self.placeholder attributes:
                                      @{NSForegroundColorAttributeName:color,
                                        NSFontAttributeName:self.font
                                        }];
    
    self.attributedPlaceholder = attrString;
}



- (void)borderLineColor:(UIColor *)color wdith:(CGFloat)wdith cornerRadius:(CGFloat)cornerRadius {
    
        // 设置线的填充色
        [color setStroke];
    
        // 新建一个bezier对象，此对象用于绘制一个圆角矩形
        UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
                                                              cornerRadius:cornerRadius];
    
        CAShapeLayer *shapeLayer = [CAShapeLayer layer];
        shapeLayer.strokeColor = color.CGColor;
        shapeLayer.fillColor = [UIColor clearColor].CGColor;
        shapeLayer.lineWidth = wdith;
        shapeLayer.lineJoin = kCALineJoinRound;
        shapeLayer.lineCap = kCALineCapRound;
        shapeLayer.path = bezierPath.CGPath;
    
        [self.layer addSublayer:shapeLayer];

}



@end
